package com.sgb.kjwl.view.ui.adapter.manage;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;

import androidx.core.util.Pair;

import com.sgb.kjwl.BR;
import com.sgb.kjwl.R;
import com.sgb.kjwl.databinding.ItemTradeHonorBinding;
import com.sgb.kjwl.model.entity.manage.TradeHonorEntity;
import com.sgb.kjwl.utils.ActivityJump;
import com.sgb.kjwl.view.ui.activity.manage.ShopInfoForCompanyTradesActivity;
import com.sgb.kjwl.view.ui.activity.manage.WebsiteInfoActivity;
import com.swgk.core.recyclerview.adapter.BaseRecycleAdapter;
import com.swgk.core.recyclerview.adapter.ItemViewHolder;

import java.util.List;

public class TradeHonorAdapter extends BaseRecycleAdapter<TradeHonorEntity> {

    public TradeHonorAdapter(Context context, List<TradeHonorEntity> datas) {
        super(context, R.layout.item_trade_honor, datas);
    }

    @Override
    public void convert(ItemViewHolder holder, TradeHonorEntity tradeHonorEntity) {
        holder.setBinding(BR.viewModel, tradeHonorEntity);
        holder.setBinding(BR.adapter, tradeHonorEntity);
        ItemTradeHonorBinding binding = (ItemTradeHonorBinding) holder.getmBinding();
        binding.btnEnterEnterprise.setOnClickListener(view ->{
                    if(!TextUtils.isEmpty(tradeHonorEntity.getCompanyNo())){
                        WebsiteInfoActivity.start(context,tradeHonorEntity.getCompanyNo(),1);
                    }else {
                        Toast.makeText(context,"公司编号不能为空!",Toast.LENGTH_LONG).show();
                    }
                });
        binding.tvLine.setVisibility(View.VISIBLE);
        if (tradeHonorEntity.getIndustryType() == null || tradeHonorEntity.getIndustryType().equals("")) {
            binding.tvLine.setVisibility(View.GONE);
            binding.tvTradeType.setVisibility(View.GONE);
        } else {
            binding.tvTradeType.setVisibility(View.VISIBLE);
        }

        if (tradeHonorEntity.getHonorLevelName() == null || tradeHonorEntity.getHonorLevelName().equals("")) {
            binding.tvLine.setVisibility(View.GONE);
            binding.tvCategory.setVisibility(View.GONE);
        } else {
            binding.tvCategory.setVisibility(View.VISIBLE);
        }
    }

}
